package videos;

import utility.Check_Net;
import utility.SDialog;
import android.app.Activity;
import android.app.ProgressDialog;
import android.content.Intent;
import android.content.pm.ActivityInfo;
import android.net.Uri;
import android.os.AsyncTask;
import android.os.Bundle;
import android.util.DisplayMetrics;
import android.util.Log;
import android.view.Window;
import android.view.WindowManager;
import android.widget.MediaController;
import android.widget.VideoView;
import example.demo_navi.R;

public class Main_4 extends Activity{

	private VideoView viv;
	String str;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		requestWindowFeature(Window.FEATURE_NO_TITLE);
		getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
		
		setContentView(R.layout.videoview);
		viv=(VideoView) findViewById(R.id.vivi);
		Intent in=getIntent();
		str=in.getDataString();
		Log.d("Holle Wor", str);
		promain4 pr=new promain4();
		if(Check_Net.isOnLine(Main_4.this)){
		pr.execute();
		}else{
			SDialog.Dialognet(Main_4.this);
		}
	}

	private class promain4 extends AsyncTask<Void, Void, Void>{

		private ProgressDialog pd;
		
		@Override
		protected Void doInBackground(Void... params) {
			// TODO Auto-generated method stub
			viv.setVideoURI(Uri.parse(str));
			return null;
		}

		@Override
		protected void onPostExecute(Void result) {
			// TODO Auto-generated method stub
			pd.dismiss();
			setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
			
			MediaController mc=new MediaController(Main_4.this);
			viv.setMediaController(mc);
			viv.requestFocus();
			viv.start();
		}

		@Override
		protected void onPreExecute() {
			// TODO Auto-generated method stub
			pd=new ProgressDialog(Main_4.this);
			pd.setProgressStyle(ProgressDialog.STYLE_SPINNER);
			pd.setMessage("Loading Video...");
			pd.show();
		}
		
	}
}
